Day 11 - Find and replace text

Solutions to exercises

Exercise 11.01

Using grep and wc, count how many times the file examples.txt contains the word dog

Solution

$ grep "dog" examples.txt | wc -l

3

Go back to the exercise

Exercise 11.02

Print all the lines of examples.txt that do not contain either a lowercase or an uppercase h

Solution

$ grep -vi "h" examples.txt

dog

cat

dryad

dog

Police 101

aardvark

[...]

The lesson doesn’t tell you how to reverse-match the given string, so you need to read the man page

for grep, which says